<?php

require_once 'glue.php';

require_once 'CheckAuth.php';
require_once 'UserJourneys.php';
require_once 'UserJourneysStatus.php';
require_once 'WishJourneys.php';
require_once 'Users.php';
require_once 'UserContacts.php';
require_once 'UserTongues.php';
require_once 'UserMessages.php';
require_once 'SubscribeJourney.php';

$urls = array(
    '/checkAuth' => 'CheckAuth',
    '/checkAuth\?.+' => 'CheckAuth'
);

session_start();
if (isset($_SESSION['SIGNATURE'])) {
    $signature = md5("SIGNATURE=" . md5($_SERVER['HTTP_USER_AGENT']));
    if ($_SESSION['SIGNATURE'] == $signature ) {
        $urls += array(
            '/userJourneys' => 'UserJourneys',
            '/userJourneys\?.+' => 'UserJourneys',
            '/userJourneysStatus\?.+' => 'UserJourneysStatus',
            '/wishJourneys\?.+' => 'WishJourneys',
            '/users\?.+' => 'Users',
            '/users' => 'Users',
            '/userContacts\?.+' => 'UserContacts',
            '/userTongues\?.+' => 'UserTongues',
            '/userContacts' => 'UserContacts',
            '/userTongues' => 'UserTongues',
            '/userMessages\?.+' => 'UserMessages',
            '/userMessages' => 'UserMessages',
            '/subscribeJourney' => 'SubscribeJourney',
            '/journeySubscribers\?.+' => 'JourneySubscribers'
        );
    }
}

try {
    glue::stick($urls);
} catch (Exception $e) {
    RestUtils::sendResponse(404);
}

?>
